cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=1")

project(TestAMCAXExchange)

add_compile_options("-std=c++17")
if(WIN32)
  add_compile_options("/std:c++17")
endif()

if(DEFINED ENV{EXCHANE_SDK})
     SET(EXCHANE_SDK $ENV{EXCHANE_SDK}) 
else()
     SET(EXCHANE_SDK ${EXCHANE_SDK}/..)
endif()

add_definitions(-DUSING_COMMAND_LINE)

if(InterOp STREQUAL "on")
  add_definitions(-DINTEROP_ENABLE)
endif()

include_directories(${EXCHANE_SDK}/include)
link_directories(${EXCHANE_SDK}/lib)

if(NOT CMAKE_TOOLCHAIN_FILE)
  set(CONAN_DIR ${CMAKE_SOURCE_DIR}/.conan/${CMAKE_BUILD_TYPE})
  include(${CONAN_DIR}/conan_toolchain.cmake)
endif()

# json
find_package(nlohmann_json REQUIRED)
list(APPEND CONAN_PUBLIC_LIBRARIES nlohmann_json::nlohmann_json)


add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} PRIVATE AMCAXExchange )
target_link_libraries(${PROJECT_NAME} PUBLIC ${CONAN_PUBLIC_LIBRARIES} )
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
      message(STATUS "GCC version: ${CMAKE_CXX_COMPILER_VERSION}")

      if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.4)
          
          add_definitions(-DCXX_LESS_17)
      else()
          target_link_libraries(${PROJECT_NAME} PRIVATE  stdc++fs)
      endif()
  endif()




file(COPY ${EXCHANE_SDK}/bin/
     DESTINATION ${CMAKE_BINARY_DIR})
